<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="box"></ul>

    <script>
        const ul = document.getElementById('box')
        const clone = ul.cloneNode(true) // 深度克隆,克隆一份ul
        // const fragment = document.createDocumentFragment() // 创建虚拟的文档片段

        // ul.style.display = 'none'
        for (let i = 0;i < 100; i++){
            let li = document.createElement('li')
            let text = document.createTextNode(i)
            li.appendChild(text)
            // fragment.appendChild(li)
            clone.appendChild(li)
        }

        ul.parentNode.replaceChild(clone,ul) // 替换节点
        // ul.appendChild(fragment)
        // ul.style.display = 'block'
    </script>
</body>
</html>